# 定义商品信息列表，每个元素是一个包含名称、数量、单价、金额的元组
products = [
    ("金士顿U盘8G", 1, 40.00, 40.00),
    ("胜创16GTF卡", 1, 50.00, 50.00),
    ("读卡器", 1, 8.00, 8.00),
    ("网线2米", 1, 5.00, 5.00)
]

# 计算总数和总额
total_count = len(products)
total_amount = sum(product[3] for product in products)

# 设置折扣（例如8.5折）
discount_rate = 0.85  # 1.0表示无折扣，0.85表示85折
discount_amount = total_amount * discount_rate

# 实收金额（可以根据实际收款修改）
received = 100.00
change = received - discount_amount

# 打印小票头部信息
print("--------------------------------------------")
print("单号: DH202311010001")
print("时间: 2023-11-01 20:56:15")
print("--------------------------------------------")
print(f"{'名称':<15}{'数量':<8}{'单价':<8}{'金额':<8}")
print("--------------------------------------------")

# 打印每个商品的信息
for product in products:
    name, count, price, amount = product
    print(f"{name:<15}{count:<8}{price:<8.2f}{amount:<8.2f}")

print("--------------------------------------------")
# 将总数和总额放在同一行
print(f"总数: {total_count:<10}总额: {total_amount:.2f}")
# 显示折扣信息
print(f"折扣: {discount_rate*10:.1f}折")
print(f"折后总额: {discount_amount:.2f}")
# 将实收和找零放在同一行
print(f"实收: {received:.2f}{'':<6}找零: {change:.2f}")
print("收银: 管理员")
print("--------------------------------------------")


    
